<!--
 * @Descripttion: 
 * @Author: voanit
 * @Date: 2022-09-14 15:36:37
 * @LastEditors: voanit
 * @LastEditTime: 2022-09-14 15:43:10
-->
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>

  <script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.1/jquery.slim.min.js"></script>
  <style>
    .active {
      background-color: red;
    }
  </style>
</head>

<body>
  <ul>
    <li>这是第1个li</li>
    <li>这是第2个li</li>
    <li>这是第3个li</li>
    <li>这是第4个li</li>
  </ul>
  <script>
    $(function () {
      /* 可以出现多次 */
      $('ul li').on('click', function () {
        console.log($(this)[0], 111);
        // $(this).addClass('active')
        $(this).addClass('active').siblings('li').removeClass('active')
      })
    })
    // $(document).ready(function () {
    //   /* window.onload  只出现一次 */
    // })
  </script>
</body>

</html>